import { IHeaderInfo } from '@/typings';
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import Home from '../views/Home.vue';

//3个页面的header信息
export const headerInfos: Array<IHeaderInfo> = [
  {
    //路由名称
    name: 'Home',
    //header标题
    title: '新闻头条',
    //图标显示位置
    left: false,
    right: true,
    leftIcon: '',
    rightIcon: 'mine', //iconfont icon-mine
    leftPath: '',
    rightPath: '/mynews'
  },
  {
    name: 'Detail',
    title: '新闻详情',
    left: true,
    right: true,
    leftIcon: 'arrow-left',
    rightIcon: 'star-o',
    leftPath: '',
    rightPath: ''
  },
  {
    name: 'MyNews',
    title: '收藏列表',
    left: true,
    right: false,
    leftIcon: 'arrow-left',
    rightIcon: '',
    leftPath: '',
    rightPath: ''
  }
];

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/detail/:uniquekey/:pagefrom',
    name: 'Detail',
    //异步动态加载组件，打包时别名detail.js
    component: () =>
      import(/* webpackChunkName: "detail" */ '../views/Detail.vue')
  },
  {
    path: '/mynews',
    name: 'MyNews',
    component: () =>
      import(/* webpackChunkName: "mynews" */ '../views/MyNews.vue')
  }
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
});

export default router;
